package bibarchmus;

import nanoxml.*;
import java.io.*;
import java.util.*;
public class DumpXML
{
  public static String fileComponent(String filename) {
      int i = filename.lastIndexOf(File.separator);
      return (i > -1) ? filename.substring(i + 1) : filename;
  }
  
  public static void main(String[] args)
      throws Exception
        {

	    FileReader reader = new FileReader("test.xml");
	    XMLElement xml = new XMLElement();
	    xml.parseFromReader(reader);
		
		Enumeration enumChild = xml.enumerateChildren();
	    XMLElement xml1 = (XMLElement)enumChild.nextElement(); //Tracklist

		 // System.out.println("ELEMENTO"+xml1+"\n"); 
		  int grandChildNumber = xml1.countChildren();
		  Enumeration enumGchild = xml1.enumerateChildren();
		  
		  for (int j= 0; j<grandChildNumber; j++){  // Estos son los tracks
		   XMLElement xml2 = (XMLElement) enumGchild.nextElement();
		 //  System.out.println("EL NIETO"+xml2);
		   Enumeration tracks = xml2.enumerateChildren();
		   String localiz = null;
		   String title = null;
		   String creator = null;
		   XMLElement xml3 = (XMLElement)tracks.nextElement();
		  while(localiz == null || title ==null || creator ==null){ 

			if (xml3.getName().compareTo("location") == 0){
			localiz = xml3.getContent();
			System.out.println(localiz);
			}
			else if (xml3.getName().compareTo("title") == 0){
		    title = xml3.getContent();
			System.out.println(title);
			}
			else if (xml3.getName().compareTo("creator") == 0){
			creator = xml3.getContent();
			System.out.println(creator);
			}
			xml3 = (XMLElement)tracks.nextElement();
		  }
		
		}
	  }
	  
 }